<?php
// +----------------------------------------------------------------------
// | TagCloud(标签云
// +----------------------------------------------------------------------
// | @link ( http://www.yurnero.net )
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: TagCloudWidget.class.php 101 2011-04-22 10:10:57Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class TagCloudWidget extends Widget {

	/**
	 * 构造标签云
	 * 
	 */
	public function render($data) {
	
		$tags  =  f_static_cache('tag_static','',ROOT_PATH . STATIC_CACHES_DIR);
		/* 标签着色,字体大小,加粗 */
		tag_cloud($tags);
	    $output = '';
		$output .= '<!-- TagCloud: START -->'."\n";
		$output .= " <li class=\"widget widget_tag_cloud dbx-box\">\n";
		$output .= "  <h3 class=\"dbx-handle\">Tags</h3>\n";
		$output .= "   <div class=\"dbx-content\">\n";
		foreach ($tags as $k=>$v) {
			$output	.= "    <a href=\"".__APP__."/Tag/".$v['tag_url']."/\" class=\"tag-link-".$v['tag_id']."\" title=\"".$v['posts_num']." topics\" style=\"font-size:".$v['size']."; color:".$v['color'].";\">";
			if ($v['bold']) {
				$output	.= "<b>".$v['tag_name']."</b></a>\n";
			} else {
				$output	.= $v['tag_name']."</a>\n";
			}
		}
		$output .= "  </div>\n";
		$output .= " </li>\n";
		$output .= ' <!-- TagCloud: END -->'."\n";

		return $output;
	}

}

?>